import { request } from './request'
export interface ILoginParams {
  account: string
  password: string
}
interface ISmsParams {
  type: number // 短信类型（1-平台登录验证码 2-重置密码验证码 3-平台注册验证码 4-通用短信验证码）
  phone: string
}

export function sendSms(params: ISmsParams) {
  return request.post('/sms/send', params)
}

export function login(params: ILoginParams) {
  return request.post('/sys/auth/login', params)
}

export function logout() {
  return request.post('/sys/auth/logout')
}

export interface IPhoneLoginParams {
  captcha: string
  phone: string
}

export function phoneLogin(params: IPhoneLoginParams) {
  return request.post('/sys/auth/phoneLogin', params)
}

export interface IChangePasswordParams {
  newPassword: string
  oldPassword: string
}

export function changePassword(params: IChangePasswordParams) {
  return request.post('/sys/auth/putPwd', params)
}

export interface IRegisterParams {
  phone: string
  captcha: string
  password: string
}

export function register(params: IRegisterParams) {
  console.error('缺少接口', params)
  return Promise.resolve('缺少注册接口')
  // return request.post('/sys/auth/addUser', params)
}
